#include <stdio.h>
#include <string.h>
#include <stdlib.h>

unsigned int* fibs;

unsigned int fib(int n){
//    printf("get at %d\n",n);
    if(n>2){
        if(fibs[n-1]==0){
            fibs[n-1]=fib(n-1);
        }
        return fibs[n-1]+fibs[n-2];
    }
    if(n==1 || n==2){
        return 1;
    }
}

int main(int argc,char** argv){
    if(argc<2){
        printf("usage : command fib-position\n");
        exit(-1);
    }
    int pos=atoi(argv[1]);
    if(pos > 47){
        printf("can't calculate pos max than 47\n");
        exit(1);
    }
    int bytes=sizeof(int)*pos;
    fibs=malloc(bytes);
    memset(fibs,bytes,0);
    fibs[1]=1;fibs[2]=1;
    printf("fib at %d is %u\n",pos,fib(pos));
}
